//
//  GYNewShopGoodCell.m
//  GYDemo
//
//  Created by Mrzhang on 2018/6/27.
//  Copyright © 2018年 mac. All rights reserved.
//

#import "GYNewShopGoodCell.h"
#import "Head.h"
#import "GYCategoryViewModel.h"
@implementation GYNewShopGoodCell



-(void)setmodel:(NSArray *)modelArr type:(NSInteger)type
{
    [self.contentView removeAllSubviews];
    float ww=WFCGFloatX(177);
    float pp=ww+WFCGFloatX(7);
    @WeakSelf;
    for (int i=0; i<modelArr.count; i++)
    {
        GYNewGoodListModel* model=modelArr[i];
        
        UIView* backView=[[UIView alloc] init];
        backView.backgroundColor=[UIColor whiteColor];
        [self.contentView addSubview:backView];
        backView.x=WFCGFloatX(7)+pp*i;
        backView.y=WFCGFloatY(7);
        backView.width=ww;
        backView.height=ww+WFCGFloatY(94);
        [WFFunctions WFUIaddbordertoView:backView radius:3 width:0 color:[UIColor greenColor]];
        [backView addTapGestureRecognizerWithDelegate:self Block:^(NSInteger tag) {
            selfp.handler(model.id);
        }];
        
        
        
        UIImageView* imageIV=[[UIImageView alloc] init];
        imageIV.x=0;
        imageIV.y=0;
        imageIV.width=ww;
        imageIV.height=ww;
        [WFFunctions addCornerToView:imageIV radius:3 corner:UIRectCornerTopLeft|UIRectCornerTopRight];
        [backView addSubview:imageIV];
        
        
        
        UILabel* nameLB=[[UILabel alloc] init];
        nameLB.x=WFCGFloatX(7);
        nameLB.y=ww+WFCGFloatY(7);
        nameLB.width=ww-WFCGFloatX(14);
        nameLB.height=WFCGFloatY(20);
        nameLB.font=SYSTEMFONT(14);
        nameLB.textColor=HEXCOLOR(@"#333333");
        [backView addSubview:nameLB];
        
        
        UILabel* priceLab=[[UILabel alloc] init];
        priceLab.x=WFCGFloatX(7);
        priceLab.y=ww+WFCGFloatY(41);
        priceLab.width=ww-WFCGFloatX(14);
        priceLab.height=WFCGFloatY(25);
        priceLab.font=SYSTEMFONT(14);
        priceLab.textColor=HEXCOLOR(@"#FC1B36");
        [backView addSubview:priceLab];
        priceLab.text=@"100000";
        
        
        UILabel* dealCountLab=[[UILabel alloc] init];
        dealCountLab.x=WFCGFloatX(7);
        dealCountLab.y=ww+WFCGFloatY(69);
        dealCountLab.width=ww-WFCGFloatX(14);
        dealCountLab.height=WFCGFloatY(15);
        dealCountLab.font=SYSTEMFONT(11);
        dealCountLab.textColor=HEXCOLOR(@"#A4AAB3");
        [backView addSubview:dealCountLab];
        dealCountLab.text=@"销量:2000 信誉等级:AAA级";
        
        
        NSString* markStr=@"¥";
        NSString* money=[NSString stringWithFormat:@"%ld",model.price];
        NSString* price=[NSString stringWithFormat:@"%@%@",markStr,money];
        
        
        NSMutableAttributedString *mastr = [[NSMutableAttributedString alloc]initWithString:price];
        [mastr addAttribute:NSFontAttributeName value:SYSTEMFONT(10) range:[price rangeOfString:markStr]];
        [mastr addAttribute:NSFontAttributeName value:SYSTEMFONT(20) range:[price rangeOfString:money]];
        priceLab.attributedText = mastr;
        
        [imageIV sd_setImageWithURL:[NSURL URLWithString:model.picurl] placeholderImage:DefaultImage];
        nameLB.text=model.name;
        dealCountLab.text=[NSString stringWithFormat:@"销量:%ld 信誉等级:%@",model.salecount,model.xlevel];
        
        
    }
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
